//
//  WebDetailInfoViewController.m
//  PeopleStreet
//
//  Created by 喻飞 on 16/3/24.
//  Copyright © 2016年 yuf. All rights reserved.
//

#import "WebDetailInfoViewController.h"
#import "NJKWebViewProgressView.h"

@interface WebDetailInfoViewController ()
{
    NJKWebViewProgressView *_progressView;
    NJKWebViewProgress *_progressProxy;
}
@end

@implementation WebDetailInfoViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navgationView addSubview:_progressView];
}
-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    
    [_progressView removeFromSuperview];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    if (self.objectId) {
        self.objectId = [NSString stringWithFormat:@"%@",self.objectId];
    }
    [self initViewLayout];
    [self.navgationTitleLabel setTitle:self.titleStr forState:UIControlStateNormal];
    if (self.meType) {
        self.meType = [NSString stringWithFormat:@"%@",self.meType];
        [self loadNoticeData];
    }else{
        [self loadData];
    }
//    [self updatefincation];
}
- (void)initViewLayout{
    [self adaptiveViewLayout:self.view];
    [self adaptiveViewLayout:self.navgationView];
    [self adaptiveViewLayout:self.webView];
    
    
    self.webView.delegate = self;
}
- (IBAction)backClick:(UIButton *)sender {
    [self.navigationController  popViewControllerAnimated:YES];
}
//问题详情
-(void)loadData{
    if([self.objectId isEqualToString:@"3"]){
        //平台简介
        NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",IP_Address_WEB,SX_queryPlatform]]];
        [_webView loadRequest:req];
    }else{
        NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@?helpId=%@",IP_Address_WEB,SX_queryAppUsingHelpDetailTag,self.objectId]]];
        [_webView loadRequest:req];
    }
    
}
//通知详情
-(void)loadNoticeData{
    if(self.meType){
        if([self.meType isEqualToString:@"4"]){
            NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:self.objectId]];
            [_webView loadRequest:req];
        }else{
           
            NSString *userId = @"";
            if ([Common getLoginStatus]) {
                 NSDictionary * dic1 =  [Common getLoginInfo];
                userId = dic1[@"userId"];
            }
            NSURLRequest *req = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@?messageId=%@&isOk=-1&&userId=%@&messageTypeId=%@",IP_Address_WEB,SX_queryMessageInfo,self.objectId,userId,self.meType]]];
            [_webView loadRequest:req];
        }
        
    }
    
}
#pragma mark === 	查看详情修改为已读状态
- (void)updatefincation{
    if (!self.meType) {
        return;
    }
    if([self.meType isEqualToString:@"4"]){
        return;
    }
    NSMutableDictionary  *dic=[NSMutableDictionary dictionary];
    self.shareApi.delegate=self;
    [dic setObject:self.objectId forKey:@"mmmId"];
    [self.shareApi  requestOperationWithDic:dic withPath:SX_updatefincation withHttpType:@"POST" withTag:SX_updatefincationTag];
}
#pragma mark - NJKWebViewProgressDelegate
-(void)webViewProgress:(NJKWebViewProgress *)webViewProgress updateProgress:(float)progress
{
    [_progressView setProgress:progress animated:YES];
}
#pragma   mark---- GetADBanner Request Delegate

-(void)fetchDatabaseFinished:(NSMutableDictionary *)database withTag:(NSInteger)tag{
    if (tag == SX_updatefincationTag){
        if (  [[database valueForKey:@"type"] integerValue]!=1 ) {
            
            [[CWHUDTips sharedInstance]  showTips:[database valueForKey:@"msg"]  withStatus:1 dismissAfter:1.5];
            
        }else  {
           
        }
    }
}
-(void)fetchDatabaseFailed:(NSError *)error message:(NSString *)message{
    
    //
    [self dismissWaitDialog];
    
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}




@end
